from django.db import models


# Create your models here.
class Institution(models.Model):
    ins_name = models.CharField(verbose_name='学院名', max_length=255)

    class Meta:
        verbose_name = '学院管理'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.ins_name


class Class(models.Model):
    classname = models.CharField(verbose_name='专业班级名', max_length=255)
    ins = models.ForeignKey(Institution, verbose_name='学院名', null=True, blank=True, on_delete=models.SET_NULL)
    wx_group = models.CharField(verbose_name='微信群id', null=True, blank=True, max_length=255)

    class Meta:
        verbose_name = '专业班级信息'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.classname


class Student(models.Model):
    name = models.CharField(verbose_name='姓名', max_length=32, null=False, blank=False)
    gender = models.IntegerField(verbose_name='性别', choices=((1, '男'), (0, '女'), (-1, '未知')), default=-1)
    cla = models.ForeignKey(Class, verbose_name='班级', null=True, blank=True, on_delete=models.SET_NULL)
    nation = models.CharField(verbose_name='民族', max_length=255, null=True, blank=True)
    idcard = models.CharField(verbose_name='身份证', max_length=18, null=True, blank=True)
    stu_card = models.CharField(verbose_name='学号', max_length=7, null=True, blank=True)
    phone = models.CharField(verbose_name='手机号', max_length=11, null=True, blank=True)
    dorm = models.CharField(verbose_name='寝室', max_length=255, null=True, blank=True)
    admission_time = models.DateTimeField(verbose_name='入学时间', null=True, blank=True)
    status = models.IntegerField(verbose_name='在校情况', null=True, blank=True, default=0,
                                 choices=((0, '在校'), (1, '不在校'), (2, '其他')))
    wx_id = models.CharField(verbose_name='微信id', null=True, blank=True, max_length=255)

    class Meta:
        verbose_name = '学生信息'
        verbose_name_plural = verbose_name

    def __str__(self):
        return f"【{self.cla}】{self.name}"


class Employment(models.Model):
    student = models.ForeignKey(Student, verbose_name='学生', null=False, blank=False, on_delete=models.CASCADE)
    unit = models.CharField(verbose_name='就业单位名(地址)', max_length=255, null=False, blank=False)

    class Meta:
        verbose_name = '就业信息'
        verbose_name_plural = verbose_name

    def __str__(self):
        return f"【{self.student.name}】{self.unit}"
